# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request
import werkzeug
from odoo.addons.web.controllers.main import Database


class DbTool(Database):
    @http.route('')
    def manager(self, **kw):
        if not request.session.uid:
            return werkzeug.utils.redirect('/web/login', 303)
        user = request.env['res.users'].sudo().browse(request.session.uid)
        if not user._is_system():
            return werkzeug.utils.redirect('web/404', 303)
        return super(DbTool,self).manager()

    @http.route('')
    def selector(self, **kw):
        if not request.session.uid:
            return werkzeug.utils.redirect('/web', 303)
        user = request.env['res.users'].sudo().browse(request.session.uid)
        if not user._is_system():
            return werkzeug.utils.redirect('/web', 303)
        return super(DbTool, self).selector()